﻿using System;
using System.Runtime.CompilerServices;
using Internal.Runtime.Services.Battle;
using Internal.Runtime.Services.BattleSkill;
using Runtime.Models;
using Runtime.Services.Battle;
using Runtime.Services.Battle.Entity;
using UnityEngine;

namespace Runtime.Services.BattleSkill {

    /// <summary>
    /// 战斗Buff提供者
    /// </summary>
    public interface IDFR_BattleBuffProvider : IDisposable {

        IDFR_BattleBuffProviderSetter AsSetter();

        /// <summary>
        /// 拥有者实例ID
        /// </summary>
        DFR_BattleEntityInstanceID OwnerEntityInstanceID { get; }

        /// <summary>
        /// 来源实例ID
        /// </summary>
        DFR_BattleEntityInstanceID SourceEntityInstanceID { get; }

        /// <summary>
        /// 实例ID
        /// </summary>
        DFR_BattleEntityInstanceID EntityInstanceID { get; }

        /// <summary>
        /// 是否启用持久化
        /// </summary>
        bool IsEnablePersistence { get; }

        IDFR_ReadOnlyBattleData HPBase { get; }

        IDFR_ReadOnlyBattleData HPFactor { get; }

        IDFR_ReadOnlyBattleData HPAdditional { get; }

        IDFR_ReadOnlyBattleData HPMaxBase { get; }

        IDFR_ReadOnlyBattleData HPMaxFactor { get; }

        IDFR_ReadOnlyBattleData HPMaxAdditional { get; }

        IDFR_ReadOnlyBattleData DamageHPMaxBase { get; }

        IDFR_ReadOnlyBattleData DamageHPMaxFactor { get; }

        IDFR_ReadOnlyBattleData DamageHPMaxAdditional { get; }

        IDFR_ReadOnlyBattleData DamageHPBase { get; }

        IDFR_ReadOnlyBattleData DamageHPFactor { get; }

        IDFR_ReadOnlyBattleData DamageHPAdditional { get; }

        IDFR_ReadOnlyBattleData DamageBase { get; }

        IDFR_ReadOnlyBattleData DamageFactor { get; }

        IDFR_ReadOnlyBattleData DamageAdditional { get; }

        IDFR_ReadOnlyBattleData AttackBase { get; }

        IDFR_ReadOnlyBattleData AttackFactor { get; }

        IDFR_ReadOnlyBattleData AttackAdditional { get; }

        IDFR_ReadOnlyBattleData AttackBossAdditionalBase { get; }

        IDFR_ReadOnlyBattleData AttackBossAdditionalFactor { get; }

        IDFR_ReadOnlyBattleData AttackBossAdditionalAdditional { get; }

        IDFR_ReadOnlyBattleData AttackSpeedBase { get; }

        IDFR_ReadOnlyBattleData AttackSpeedFactor { get; }

        IDFR_ReadOnlyBattleData AttackSpeedAdditional { get; }

        IDFR_ReadOnlyBattleData CriticalBase { get; }

        IDFR_ReadOnlyBattleData CriticalFactor { get; }

        IDFR_ReadOnlyBattleData CriticalAdditional { get; }

        IDFR_ReadOnlyBattleData CriticalPowerBase { get; }

        IDFR_ReadOnlyBattleData CriticalPowerFactor { get; }

        IDFR_ReadOnlyBattleData CriticalPowerAdditional { get; }

        IDFR_ReadOnlyBattleData SpottingRangeBase { get; }

        IDFR_ReadOnlyBattleData SpottingRangeFactor { get; }

        IDFR_ReadOnlyBattleData SpottingRangeAdditional { get; }

        IDFR_ReadOnlyBattleData MoveSpeedBase { get; }

        IDFR_ReadOnlyBattleData MoveSpeedFactor { get; }

        IDFR_ReadOnlyBattleData MoveSpeedAdditional { get; }

        IDFR_ReadOnlyBattleData DefenseBase { get; }

        IDFR_ReadOnlyBattleData DefenseFactor { get; }

        IDFR_ReadOnlyBattleData DefenseAdditional { get; }

        IDFR_ReadOnlyBattleData DodgeBase { get; }

        IDFR_ReadOnlyBattleData DodgeFactor { get; }

        IDFR_ReadOnlyBattleData DodgeAdditional { get; }

        IDFR_ReadOnlyBattleData InfluenceAmountAdditional { get; }
    }

    public interface IDFR_BattleBuffProviderSetter : IDFR_BattleBuffProvider {

        /// <summary>
        /// 添加Buff
        /// </summary>
        /// <param name="source">来源</param>
        void AttachBuff(IDFR_BattleBuffProvider source);

        /// <summary>
        /// 移除Buff
        /// </summary>
        /// <param name="source">来源</param>
        void DetachBuff(IDFR_BattleBuffProvider source);
    }

    [Implement(typeof(IDFR_BattleBuffProvider))]
    [Implement(typeof(IDFR_BattleBuffProviderSetter))]
    internal sealed class DFR_BattleBuffProvider : DFR_PoolEntity, IDFR_BattleBuffProvider, IDFR_BattleBuffProviderSetter, IDFR_BattleBuffProviderInternal, IDFR_BattleEffectHolder, IDFR_BattleEffectHolderSetter, IDFR_BattleEffectHolderInternal {

        public IDFR_BattleBuffProviderSetter AsSetter() {
            AssertDispose();
            return this;
        }

        IDFR_BattleEffectHolderSetter IDFR_BattleEffectHolder.AsSetter() {
            AssertDispose();
            return this;
        }

        protected override void Allocate() {
        }

        protected override void Release() {
            m_OwnerEntityInstanceID = DFR_BattleEntityInstanceID.Empty;
            m_SourceEntityInstanceID = DFR_BattleEntityInstanceID.Empty;
            m_InstanceID = DFR_BattleEntityInstanceID.Empty;
            m_EntityHandle = DFR_BattleEntityHandle.Empty;
            m_ModelAssetKey = null;
            m_HasModelAsset = false;
            m_IsEnableFilter = false;
            m_SyncPositionEntityInstanceID = DFR_BattleEntityInstanceID.Empty;
            m_IsSyncPositionAlways = false;
            m_IsSyncPositionOnce = false;
            m_IsEnablePersistence = false;
        }

        private DFR_BattleEntityInstanceID m_OwnerEntityInstanceID;
        public DFR_BattleEntityInstanceID OwnerEntityInstanceID {
            get {
                AssertDispose();
                return m_OwnerEntityInstanceID;
            }
        }

        private DFR_BattleEntityInstanceID m_SourceEntityInstanceID;
        public DFR_BattleEntityInstanceID SourceEntityInstanceID {
            get {
                AssertDispose();
                return m_SourceEntityInstanceID;
            }
        }

        private DFR_BattleEntityInstanceID m_InstanceID;
        public DFR_BattleEntityInstanceID EntityInstanceID {
            get {
                AssertDispose();
                return m_InstanceID;
            }
        }

        private DFR_BattleEntityHandle m_EntityHandle;
        public DFR_BattleEntityHandle EntityHandle {
            get {
                AssertDispose();
                return m_EntityHandle;
            }
        }

        void IDFR_BattleEffectHolderInternal.SetEntityHandle(DFR_BattleEntityHandle value) {
            AssertDispose();
            m_EntityHandle = value;
        }

        private bool m_IsSyncPositionAlways;
        private bool m_IsSyncPositionOnce;
        private DFR_BattleEntityInstanceID m_SyncPositionEntityInstanceID;

        bool IDFR_BattleEffectHolder.RequireSyncPosition {
            get {
                AssertDispose();
                return m_IsSyncPositionAlways || m_IsSyncPositionOnce;
            }
        }

        void IDFR_BattleEffectHolderSetter.SyncPositionFrom(DFR_BattleEntityInstanceID entityInstanceID) {
            AssertDispose();
            m_IsSyncPositionAlways = entityInstanceID != DFR_BattleEntityInstanceID.Empty;
            m_IsSyncPositionOnce = false;
            m_SyncPositionEntityInstanceID = entityInstanceID;
        }
        void IDFR_BattleEffectHolderSetter.SyncPositionOnce(DFR_BattleEntityInstanceID entityInstanceID) {
            AssertDispose();
            if (m_IsSyncPositionAlways) {
                return;
            }
            if (entityInstanceID != DFR_BattleEntityInstanceID.Empty) {
                m_IsSyncPositionOnce = true;
                m_SyncPositionEntityInstanceID = entityInstanceID;
            }
        }

        Vector3 IDFR_BattleEffectHolderInternal.SyncPosition() {
            AssertDispose();
            var instanceID = m_SyncPositionEntityInstanceID;
            if (m_IsSyncPositionOnce) {
                m_IsSyncPositionOnce = false;
                m_SyncPositionEntityInstanceID = DFR_BattleEntityInstanceID.Empty;
            }
            return BattleServiceBase.Instance.GetLocalPosition(instanceID);
        }

        private string m_ModelAssetKey;
        public string ModelAssetKey {
            get {
                AssertDispose();
                return m_ModelAssetKey;
            }
        }

        private bool m_HasModelAsset;
        public bool HasModelAsset {
            get {
                AssertDispose();
                return m_HasModelAsset;
            }
        }

        void IDFR_BattleEffectHolderSetter.SetModelAssetKey(string value) {
            AssertDispose();
            m_ModelAssetKey = value;
            m_HasModelAsset = IDFR_BattleEffectModelBase.MODEL_ASSET_REGEXP.IsMatch(value);
        }

        public bool IsEnablePersistence => m_IsEnablePersistence;
        private bool m_IsEnablePersistence;
        private bool m_IsEnableFilter;

        void IDFR_BattleBuffProviderInternal.Initialize(DFR_BattleEntityInstanceID instanceID, bool isEnableFilter, DFR_BattleEntityInstanceID ownerEntityInstanceID, DFR_BattleEntityInstanceID sourceEntityInstanceID, bool isEnablePersistence) {
            AssertDispose();
            m_InstanceID = instanceID;
            m_OwnerEntityInstanceID = ownerEntityInstanceID;
            m_SourceEntityInstanceID = sourceEntityInstanceID;
            m_IsEnableFilter = isEnableFilter;
            m_IsEnablePersistence = isEnablePersistence;
            EnableFilter();
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_HPBase;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.HPBase {
            get {
                AssertDispose();
                return m_HPBase;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_HPFactor;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.HPFactor {
            get {
                AssertDispose();
                return m_HPFactor;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_HPAdditional;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.HPAdditional {
            get {
                AssertDispose();
                return m_HPAdditional;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_HPMaxBase;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.HPMaxBase {
            get {
                AssertDispose();
                return m_HPMaxBase;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_HPMaxFactor;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.HPMaxFactor {
            get {
                AssertDispose();
                return m_HPMaxFactor;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_HPMaxAdditional;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.HPMaxAdditional {
            get {
                AssertDispose();
                return m_HPMaxAdditional;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_DamageHPMaxBase;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.DamageHPMaxBase {
            get {
                AssertDispose();
                return m_DamageHPMaxBase;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_DamageHPMaxFactor;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.DamageHPMaxFactor {
            get {
                AssertDispose();
                return m_DamageHPMaxFactor;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_DamageHPMaxAdditional;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.DamageHPMaxAdditional {
            get {
                AssertDispose();
                return m_DamageHPMaxAdditional;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_DamageHPBase;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.DamageHPBase {
            get {
                AssertDispose();
                return m_DamageHPBase;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_DamageHPFactor;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.DamageHPFactor {
            get {
                AssertDispose();
                return m_DamageHPFactor;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_DamageHPAdditional;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.DamageHPAdditional {
            get {
                AssertDispose();
                return m_DamageHPAdditional;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_DamageBase;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.DamageBase {
            get {
                AssertDispose();
                return m_DamageBase;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_DamageFactor;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.DamageFactor {
            get {
                AssertDispose();
                return m_DamageFactor;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_DamageAdditional;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.DamageAdditional {
            get {
                AssertDispose();
                return m_DamageAdditional;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_AttackBase;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.AttackBase {
            get {
                AssertDispose();
                return m_AttackBase;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_AttackFactor;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.AttackFactor {
            get {
                AssertDispose();
                return m_AttackFactor;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_AttackAdditional;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.AttackAdditional {
            get {
                AssertDispose();
                return m_AttackAdditional;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_AttackBossAdditionalBase;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.AttackBossAdditionalBase {
            get {
                AssertDispose();
                return m_AttackBossAdditionalBase;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_AttackBossAdditionalFactor;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.AttackBossAdditionalFactor {
            get {
                AssertDispose();
                return m_AttackBossAdditionalFactor;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_AttackBossAdditionalAdditional;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.AttackBossAdditionalAdditional {
            get {
                AssertDispose();
                return m_AttackBossAdditionalAdditional;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_AttackSpeedBase;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.AttackSpeedBase {
            get {
                AssertDispose();
                return m_AttackSpeedBase;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_AttackSpeedFactor;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.AttackSpeedFactor {
            get {
                AssertDispose();
                return m_AttackSpeedFactor;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_AttackSpeedAdditional;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.AttackSpeedAdditional {
            get {
                AssertDispose();
                return m_AttackSpeedAdditional;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_CriticalBase;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.CriticalBase {
            get {
                AssertDispose();
                return m_CriticalBase;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_CriticalFactor;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.CriticalFactor {
            get {
                AssertDispose();
                return m_CriticalFactor;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_CriticalAdditional;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.CriticalAdditional {
            get {
                AssertDispose();
                return m_CriticalAdditional;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_CriticalPowerBase;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.CriticalPowerBase {
            get {
                AssertDispose();
                return m_CriticalPowerBase;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_CriticalPowerFactor;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.CriticalPowerFactor {
            get {
                AssertDispose();
                return m_CriticalPowerFactor;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_CriticalPowerAdditional;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.CriticalPowerAdditional {
            get {
                AssertDispose();
                return m_CriticalPowerAdditional;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_SpottingRangeBase;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.SpottingRangeBase {
            get {
                AssertDispose();
                return m_SpottingRangeBase;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_SpottingRangeFactor;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.SpottingRangeFactor {
            get {
                AssertDispose();
                return m_SpottingRangeFactor;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_SpottingRangeAdditional;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.SpottingRangeAdditional {
            get {
                AssertDispose();
                return m_SpottingRangeAdditional;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_MoveSpeedBase;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.MoveSpeedBase {
            get {
                AssertDispose();
                return m_MoveSpeedBase;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_MoveSpeedFactor;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.MoveSpeedFactor {
            get {
                AssertDispose();
                return m_MoveSpeedFactor;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_MoveSpeedAdditional;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.MoveSpeedAdditional {
            get {
                AssertDispose();
                return m_MoveSpeedAdditional;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_DefenseBase;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.DefenseBase {
            get {
                AssertDispose();
                return m_DefenseBase;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_DefenseFactor;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.DefenseFactor {
            get {
                AssertDispose();
                return m_DefenseFactor;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_DefenseAdditional;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.DefenseAdditional {
            get {
                AssertDispose();
                return m_DefenseAdditional;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_DodgeBase;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.DodgeBase {
            get {
                AssertDispose();
                return m_DodgeBase;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_DodgeFactor;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.DodgeFactor {
            get {
                AssertDispose();
                return m_DodgeFactor;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_DodgeAdditional;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.DodgeAdditional {
            get {
                AssertDispose();
                return m_DodgeAdditional;
            }
        }

        [Autowired]
        private readonly IDFR_BattleFusionData m_InfluenceAmountAdditional;
        IDFR_ReadOnlyBattleData IDFR_BattleBuffProvider.InfluenceAmountAdditional {
            get {
                AssertDispose();
                return m_InfluenceAmountAdditional;
            }
        }

        void IDFR_BattleBuffProviderSetter.AttachBuff(IDFR_BattleBuffProvider source) {
            AssertDispose();
            if (source.HPBase != null) {
                m_HPBase.Add(source.HPBase);
            }
            if (source.HPFactor != null) {
                m_HPFactor.Add(source.HPFactor);
            }
            if (source.HPAdditional != null) {
                m_HPAdditional.Add(source.HPAdditional);
            }
            if (source.HPMaxBase != null) {
                m_HPMaxBase.Add(source.HPMaxBase);
            }
            if (source.HPMaxFactor != null) {
                m_HPMaxFactor.Add(source.HPMaxFactor);
            }
            if (source.HPMaxAdditional != null) {
                m_HPMaxAdditional.Add(source.HPMaxAdditional);
            }
            if (source.DamageHPMaxBase != null) {
                m_DamageHPMaxBase.Add(source.DamageHPMaxBase);
            }
            if (source.DamageHPMaxFactor != null) {
                m_DamageHPMaxFactor.Add(source.DamageHPMaxFactor);
            }
            if (source.DamageHPMaxAdditional != null) {
                m_DamageHPMaxAdditional.Add(source.DamageHPMaxAdditional);
            }
            if (source.DamageHPBase != null) {
                m_DamageHPBase.Add(source.DamageHPBase);
            }
            if (source.DamageHPFactor != null) {
                m_DamageHPFactor.Add(source.DamageHPFactor);
            }
            if (source.DamageHPAdditional != null) {
                m_DamageHPAdditional.Add(source.DamageHPAdditional);
            }
            if (source.DamageBase != null) {
                m_DamageBase.Add(source.DamageBase);
            }
            if (source.DamageFactor != null) {
                m_DamageFactor.Add(source.DamageFactor);
            }
            if (source.DamageAdditional != null) {
                m_DamageAdditional.Add(source.DamageAdditional);
            }
            if (source.AttackBase != null) {
                m_AttackBase.Add(source.AttackBase);
            }
            if (source.AttackFactor != null) {
                m_AttackFactor.Add(source.AttackFactor);
            }
            if (source.AttackAdditional != null) {
                m_AttackAdditional.Add(source.AttackAdditional);
            }
            if (source.AttackBossAdditionalBase != null) {
                m_AttackBossAdditionalBase.Add(source.AttackBossAdditionalBase);
            }
            if (source.AttackBossAdditionalFactor != null) {
                m_AttackBossAdditionalFactor.Add(source.AttackBossAdditionalFactor);
            }
            if (source.AttackBossAdditionalAdditional != null) {
                m_AttackBossAdditionalAdditional.Add(source.AttackBossAdditionalAdditional);
            }
            if (source.AttackSpeedBase != null) {
                m_AttackSpeedBase.Add(source.AttackSpeedBase);
            }
            if (source.AttackSpeedFactor != null) {
                m_AttackSpeedFactor.Add(source.AttackSpeedFactor);
            }
            if (source.AttackSpeedAdditional != null) {
                m_AttackSpeedAdditional.Add(source.AttackSpeedAdditional);
            }
            if (source.CriticalBase != null) {
                m_CriticalBase.Add(source.CriticalBase);
            }
            if (source.CriticalFactor != null) {
                m_CriticalFactor.Add(source.CriticalFactor);
            }
            if (source.CriticalAdditional != null) {
                m_CriticalAdditional.Add(source.CriticalAdditional);
            }
            if (source.CriticalPowerBase != null) {
                m_CriticalPowerBase.Add(source.CriticalPowerBase);
            }
            if (source.CriticalPowerFactor != null) {
                m_CriticalPowerFactor.Add(source.CriticalPowerFactor);
            }
            if (source.CriticalPowerAdditional != null) {
                m_CriticalPowerAdditional.Add(source.CriticalPowerAdditional);
            }
            if (source.SpottingRangeBase != null) {
                m_SpottingRangeBase.Add(source.SpottingRangeBase);
            }
            if (source.SpottingRangeFactor != null) {
                m_SpottingRangeFactor.Add(source.SpottingRangeFactor);
            }
            if (source.SpottingRangeAdditional != null) {
                m_SpottingRangeAdditional.Add(source.SpottingRangeAdditional);
            }
            if (source.MoveSpeedBase != null) {
                m_MoveSpeedBase.Add(source.MoveSpeedBase);
            }
            if (source.MoveSpeedFactor != null) {
                m_MoveSpeedFactor.Add(source.MoveSpeedFactor);
            }
            if (source.MoveSpeedAdditional != null) {
                m_MoveSpeedAdditional.Add(source.MoveSpeedAdditional);
            }
            if (source.DefenseBase != null) {
                m_DefenseBase.Add(source.DefenseBase);
            }
            if (source.DefenseFactor != null) {
                m_DefenseFactor.Add(source.DefenseFactor);
            }
            if (source.DefenseAdditional != null) {
                m_DefenseAdditional.Add(source.DefenseAdditional);
            }
            if (source.DodgeBase != null) {
                m_DodgeBase.Add(source.DodgeBase);
            }
            if (source.DodgeFactor != null) {
                m_DodgeFactor.Add(source.DodgeFactor);
            }
            if (source.DodgeAdditional != null) {
                m_DodgeAdditional.Add(source.DodgeAdditional);
            }
            if (source.InfluenceAmountAdditional != null) {
                m_InfluenceAmountAdditional.Add(source.InfluenceAmountAdditional);
            }
        }

        void IDFR_BattleBuffProviderSetter.DetachBuff(IDFR_BattleBuffProvider source) {
            AssertDispose();

            if (source.HPBase != null) {
                m_HPBase.Remove(source.HPBase);
            }
            if (source.HPFactor != null) {
                m_HPFactor.Remove(source.HPFactor);
            }
            if (source.HPAdditional != null) {
                m_HPAdditional.Remove(source.HPAdditional);
            }
            if (source.HPMaxBase != null) {
                m_HPMaxBase.Remove(source.HPMaxBase);
            }
            if (source.HPMaxFactor != null) {
                m_HPMaxFactor.Remove(source.HPMaxFactor);
            }
            if (source.HPMaxAdditional != null) {
                m_HPMaxAdditional.Remove(source.HPMaxAdditional);
            }
            if (source.DamageHPMaxBase != null) {
                m_DamageHPMaxBase.Remove(source.DamageHPMaxBase);
            }
            if (source.DamageHPMaxFactor != null) {
                m_DamageHPMaxFactor.Remove(source.DamageHPMaxFactor);
            }
            if (source.DamageHPMaxAdditional != null) {
                m_DamageHPMaxAdditional.Remove(source.DamageHPMaxAdditional);
            }
            if (source.DamageHPBase != null) {
                m_DamageHPBase.Remove(source.DamageHPBase);
            }
            if (source.DamageHPFactor != null) {
                m_DamageHPFactor.Remove(source.DamageHPFactor);
            }
            if (source.DamageHPAdditional != null) {
                m_DamageHPAdditional.Remove(source.DamageHPAdditional);
            }
            if (source.DamageBase != null) {
                m_DamageBase.Remove(source.DamageBase);
            }
            if (source.DamageFactor != null) {
                m_DamageFactor.Remove(source.DamageFactor);
            }
            if (source.DamageAdditional != null) {
                m_DamageAdditional.Remove(source.DamageAdditional);
            }
            if (source.AttackBase != null) {
                m_AttackBase.Remove(source.AttackBase);
            }
            if (source.AttackFactor != null) {
                m_AttackFactor.Remove(source.AttackFactor);
            }
            if (source.AttackAdditional != null) {
                m_AttackAdditional.Remove(source.AttackAdditional);
            }
            if (source.AttackBossAdditionalBase != null) {
                m_AttackBossAdditionalBase.Remove(source.AttackBossAdditionalBase);
            }
            if (source.AttackBossAdditionalFactor != null) {
                m_AttackBossAdditionalFactor.Remove(source.AttackBossAdditionalFactor);
            }
            if (source.AttackBossAdditionalAdditional != null) {
                m_AttackBossAdditionalAdditional.Remove(source.AttackBossAdditionalAdditional);
            }
            if (source.AttackSpeedBase != null) {
                m_AttackSpeedBase.Remove(source.AttackSpeedBase);
            }
            if (source.AttackSpeedFactor != null) {
                m_AttackSpeedFactor.Remove(source.AttackSpeedFactor);
            }
            if (source.AttackSpeedAdditional != null) {
                m_AttackSpeedAdditional.Remove(source.AttackSpeedAdditional);
            }
            if (source.CriticalBase != null) {
                m_CriticalBase.Remove(source.CriticalBase);
            }
            if (source.CriticalFactor != null) {
                m_CriticalFactor.Remove(source.CriticalFactor);
            }
            if (source.CriticalAdditional != null) {
                m_CriticalAdditional.Remove(source.CriticalAdditional);
            }
            if (source.CriticalPowerBase != null) {
                m_CriticalPowerBase.Remove(source.CriticalPowerBase);
            }
            if (source.CriticalPowerFactor != null) {
                m_CriticalPowerFactor.Remove(source.CriticalPowerFactor);
            }
            if (source.CriticalPowerAdditional != null) {
                m_CriticalPowerAdditional.Remove(source.CriticalPowerAdditional);
            }
            if (source.SpottingRangeBase != null) {
                m_SpottingRangeBase.Remove(source.SpottingRangeBase);
            }
            if (source.SpottingRangeFactor != null) {
                m_SpottingRangeFactor.Remove(source.SpottingRangeFactor);
            }
            if (source.SpottingRangeAdditional != null) {
                m_SpottingRangeAdditional.Remove(source.SpottingRangeAdditional);
            }
            if (source.MoveSpeedBase != null) {
                m_MoveSpeedBase.Remove(source.MoveSpeedBase);
            }
            if (source.MoveSpeedFactor != null) {
                m_MoveSpeedFactor.Remove(source.MoveSpeedFactor);
            }
            if (source.MoveSpeedAdditional != null) {
                m_MoveSpeedAdditional.Remove(source.MoveSpeedAdditional);
            }
            if (source.DefenseBase != null) {
                m_DefenseBase.Remove(source.DefenseBase);
            }
            if (source.DefenseFactor != null) {
                m_DefenseFactor.Remove(source.DefenseFactor);
            }
            if (source.DefenseAdditional != null) {
                m_DefenseAdditional.Remove(source.DefenseAdditional);
            }
            if (source.DodgeBase != null) {
                m_DodgeBase.Remove(source.DodgeBase);
            }
            if (source.DodgeFactor != null) {
                m_DodgeFactor.Remove(source.DodgeFactor);
            }
            if (source.DodgeAdditional != null) {
                m_DodgeAdditional.Remove(source.DodgeAdditional);
            }
            if (source.InfluenceAmountAdditional != null) {
                m_InfluenceAmountAdditional.Remove(source.InfluenceAmountAdditional);
            }
        }

        private void EnableFilter() {
            if (m_DamageHPMaxBase == null || m_DamageHPMaxBase.IsDisposed) {
                UnityEngine.Debug.LogWarning($"{nameof(DFR_BattleBuffProvider)}正在使用已经销毁的{nameof(IDFR_BattleFusionData)}");
                return;
            }
            EnableFilter(m_HPBase);
            EnableFilter(m_HPFactor);
            EnableFilter(m_HPAdditional);
            EnableFilter(m_HPMaxBase);
            EnableFilter(m_HPMaxFactor);
            EnableFilter(m_HPMaxAdditional);
            EnableFilter(m_DamageHPBase);
            EnableFilter(m_DamageHPFactor);
            EnableFilter(m_DamageHPAdditional);
            EnableFilter(m_DamageBase);
            EnableFilter(m_DamageFactor);
            EnableFilter(m_DamageAdditional);
            EnableFilter(m_AttackBase);
            EnableFilter(m_AttackFactor);
            EnableFilter(m_AttackAdditional);
            EnableFilter(m_AttackBossAdditionalBase);
            EnableFilter(m_AttackBossAdditionalFactor);
            EnableFilter(m_AttackBossAdditionalAdditional);
            EnableFilter(m_AttackSpeedBase);
            EnableFilter(m_AttackSpeedFactor);
            EnableFilter(m_AttackSpeedAdditional);
            EnableFilter(m_CriticalBase);
            EnableFilter(m_CriticalFactor);
            EnableFilter(m_CriticalAdditional);
            EnableFilter(m_CriticalPowerBase);
            EnableFilter(m_CriticalPowerFactor);
            EnableFilter(m_CriticalPowerAdditional);
            EnableFilter(m_SpottingRangeBase);
            EnableFilter(m_SpottingRangeFactor);
            EnableFilter(m_SpottingRangeAdditional);
            EnableFilter(m_MoveSpeedBase);
            EnableFilter(m_MoveSpeedFactor);
            EnableFilter(m_MoveSpeedAdditional);
            EnableFilter(m_DefenseBase);
            EnableFilter(m_DefenseFactor);
            EnableFilter(m_DefenseAdditional);
            EnableFilter(m_DodgeBase);
            EnableFilter(m_DodgeFactor);
            EnableFilter(m_DodgeAdditional);
            EnableFilter(m_InfluenceAmountAdditional);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private void EnableFilter(IDFR_BattleFusionData fusionData) {
            if (fusionData == null || fusionData.IsDisposed) {
                UnityEngine.Debug.LogWarning($"{nameof(DFR_BattleBuffProvider)}正在使用已经销毁的{nameof(IDFR_BattleFusionData)}");
                return;
            }
            if (m_IsEnableFilter) {
                (fusionData as IDFR_BattleDataInternal).EnableFilter(m_InstanceID);
            } else {
                (fusionData as IDFR_BattleDataInternal).EnableFilter(DFR_BattleEntityInstanceID.Empty);
            }
            (fusionData as IDFR_BattleFusionDataInternal).EnableFilter(m_IsEnableFilter);
        }
    }
}

namespace Runtime.Models {

    public interface IDFR_BattleBuffProviderInternal {

        void Initialize(DFR_BattleEntityInstanceID value, bool isEnableFilter, DFR_BattleEntityInstanceID ownerEntityInstanceID, DFR_BattleEntityInstanceID sourceEntityInstanceID, bool isEnablePersistence = false);
    }
}